
<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>表增加</title>
    <link href="/static/devtools30/layui/css/layui.css" rel="stylesheet" />
    <link href="/static/devtools30/css/devindexbase.css" rel="stylesheet" />
    <script src="/static/devtools30/js/jquery-1.11.2.min.js" type="text/javascript"></script>
    <script src="/static/devtools30/layui/layui.all.js" type="text/javascript"></script>
    <script src="/static/devtools30/js/devtoolCommon.js" type="text/javascript"></script>
    <style>
        /*页面内边距*/

        .addwrap {
            padding: 30px;
        }


        /*按钮组边框*/

        .layui-btn-primary {
            border: 1px solid #C9C9C9!important;
        }


        /*输入框，下拉框子项高度*/

        .addwrap .layui-input,
        .layui-select {
            height: 25px;
        }


        /*下拉框子项高度*/

        .addwrap .layui-form-select dl {
            top: 26px;
            padding: 0;
        }


        /*下拉框子项内容高度*/

        .addwrap .layui-form-select dl dd,
        .layui-form-select dl dt {
            line-height: 24px;
        }

        .addwrap .layui-input-block {
            min-height: 26px;
            margin-left: 30px;
        }

        .addwrap .layui-form-label {
            padding: 0;
            text-align: left;
            height: 26px;
            line-height: 26px;
            width: auto;
        }
    </style>
</head>
<body>
<div class="backgroundf addwrap">
    <div class="layui-form" lay-filter="form">
        <input type="hidden" name="id" id ="id"  th:value="${data.id}"/>
        <div class="flex flex-jusity-betreen">
            <div class="layui-form-item">
                <label class="layui-form-label">序号</label>
                <div class="layui-input-block">
                    <input  id="xh" name="xh" type="number" th:value="${data.xh}" onkeydown="DigitInput(this)" lay-verify="required" lay-reqtext="序号不能为空" placeholder="请输入序号" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">分类</label>
                <div class="layui-input-block">
                    <select id="typeId" name="typeId" lay-filter="typeId">
                        <option th:each="c : ${ftypeList}" th:value="${c.id}" th:text="${c.flmc}">

                        </option>
                    </select>
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">类型</label>
            <div class="layui-input-block">
                <select id="modeltype" name="modeltype" lay-filter="modeltype">
                    <option th:each="c:${modelTypeList}" th:value="${c.value}" th:text="${c.value}" th:selected="${data.modeltype } eq ${c.value} ">

                    </option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">存储</label>
            <div class="layui-input-block">
                <select id="storetype" name="storetype" lay-filter="storetype">
                    <option value="json" th:selected="${data.storetype} eq 'json'">json</option>
                    <option value="普通" th:selected="${data.storetype} eq '普通'">普通</option>
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">名称</label>
            <div class="layui-input-block">
                <input type="text" name="name" id="name" th:value="${data.name}" lay-verify="required" lay-reqtext="表名称不能为空" placeholder="请输入名称" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">代码</label>
            <div class="layui-input-block">
                <input type="text" name="code" id="code" th:value="${data.code}" lay-verify="required" lay-reqtext="表代码不能为空" placeholder="请输入代码" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="flex flex-jusity-around tjbtn">
                <button class="layui-btn layui-btn-radius layui-btn-sm layui-btn-primary" onclick="closeWin()">取消</button>
                <button class="layui-btn layui-btn-radius layui-btn-sm " lay-submit="" lay-filter="save">保存</button>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    /*表单初始化*/
    $(function(){
        initEvent();

    });
    function closeWin(){
        dlCommon.closeParentLayer();
    }
    function initEvent(){
        layui.form.on('submit(save)', function(data){
            saveData();
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
        $("#typeId option[value='[(${data.typeId})]']").attr("selected", "selected");
        layui.form.render();
    }
    function saveData(){
        var data = layui.form.val('form');
        dlCommon.post("/DevtModelMetadataTableController/save",data,function(res){
            if(!res.success){
                dlCommon.layerError(res.msg);
                return;
            }
            dlCommon.layerSuccess("保存成功",function(){
                parent.loadData();
                closeWin();
            })
        },true)
    }
</script>
</html>
